package cn.iocoder.yudao.module.engine.controller.app.audiocommand;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.engine.controller.app.audiocommand.vo.AudioCommandRespVO;
import cn.iocoder.yudao.module.resource.api.IAudioCommandApi;
import cn.iocoder.yudao.module.resource.api.model.AudioCommandDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 语音指令配置")
@RestController
@RequestMapping("/resource/audio-command")
@Validated
public class AppAudioCommandController {
    @Resource
    private IAudioCommandApi audioCommandApi;

    @RequestMapping(value = "/get-available-commands", method = {RequestMethod.GET, RequestMethod.POST})
    @Operation(summary = "获得可用的指令配置")
    @PreAuthenticated
    public CommonResult<List<AudioCommandRespVO>> getAudioCommandPage() {
        final List<AudioCommandDTO> dtoList = audioCommandApi.getAvailableAudioCommandList();
        return success(BeanUtils.toBean(dtoList, AudioCommandRespVO.class));
    }

}